package com.aaa.controller;

import com.aaa.entity.Mhall;
import com.aaa.service.MhallService;
import com.aaa.util.DefaultMsg;
import com.aaa.util.TableData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/fangyingting")
public class MhallController {
    @Autowired
    private MhallService mhallService;
    @RequestMapping("/toList")
    public String toList(){
        return "mhall/list";

    }
    @RequestMapping("/listData")
    @ResponseBody
    public TableData<Mhall> listData(@RequestParam(defaultValue = "") String keyword, Integer page, Integer limit){
        TableData<Mhall> page1 = mhallService.page(keyword, page, limit);
        return page1;
    }
    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public DefaultMsg saveOrUpdate(Mhall mhall){
        DefaultMsg defaultMsg = mhallService.saveOrupdate(mhall);
        return defaultMsg;

    }

    @RequestMapping("/toEdit")
    public String toEdit(){
        return "mhall/edit";
    }

    @RequestMapping("/delete")
    @ResponseBody
    public DefaultMsg delete(Long id){
        DefaultMsg defaultMsg = mhallService.delete(id);
        return  defaultMsg;
    }
}
